Skip to content

Conversation

joaoantoniocardoso
Copy link
Member

@joaoantoniocardoso joaoantoniocardoso commented Oct 12, 2025

Helps #3591

Summary by Sourcery

Add support for MAVLink system and component IDs in MAVLinkServer

Enhancements:

  • Initialize mavlink_system_id and mavlink_component_id attributes in MAVLinkServer
  • Default system ID from MAV_SYSTEM_ID environment variable (falling back to 1) and default component ID to 191
  • Include --mavlink-system-id and --mavlink-component-id flags when constructing the mavlink-server command

Copy link

sourcery-ai bot commented Oct 12, 2025

Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Adds support for configurable MAVLink system and component IDs in MAVLinkServer by introducing new attributes, initializing them from environment or defaults, and passing them as command-line flags.

Class diagram for updated MAVLinkServer attributes

classDiagram
    class MAVLinkServer {
        log_path: Optional[str]
        mavlink_system_id: Optional[int]
        mavlink_component_id: Optional[int]
        __init__()
        _get_version() Optional[str]
        name() str
    }
    MAVLinkServer --|> AbstractRouter
Loading

Flow diagram for MAVLinkServer initialization of system and component IDs

flowchart TD
    A["Start MAVLinkServer initialization"] --> B["Check if log_path is set"]
    B --> C["Set log_path to default if not set"]
    C --> D["Check if mavlink_system_id is set"]
    D --> E["Set mavlink_system_id from environment or default (1)"]
    E --> F["Check if mavlink_component_id is set"]
    F --> G["Set mavlink_component_id to default (191)"]
    G --> H["Pass IDs as command-line flags"]
Loading

File-Level Changes

Change Details Files
Introduce MAVLink system and component ID attributes
  • Add optional instance variables mavlink_system_id and mavlink_component_id in init
  • Initialize mavlink_system_id from $MAV_SYSTEM_ID or default to 1
  • Initialize mavlink_component_id to default 191
core/services/ardupilot_manager/mavlink_proxy/MAVLinkServer.py
Include new MAVLink ID flags in server startup command
  • Append --mavlink-system-id and --mavlink-component-id to the constructed command string
core/services/ardupilot_manager/mavlink_proxy/MAVLinkServer.py

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there - I've reviewed your changes and they look great!

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location> `core/services/ardupilot_manager/mavlink_proxy/MAVLinkServer.py:49-51` </location>
<code_context>

         if not self.log_path:
             self.log_path = "/var/logs/blueos/services/mavlink-server/"
+        if not self.mavlink_system_id:
+            self.mavlink_system_id = int(os.getenv('MAV_SYSTEM_ID', 1))
+        if not self.mavlink_component_id:
+            self.mavlink_component_id = 191

</code_context>

<issue_to_address>
**issue:** Environment variable parsing may fail if MAV_SYSTEM_ID is not an integer.

Add error handling for non-integer MAV_SYSTEM_ID values to prevent ValueError exceptions.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines 49 to 51
if not self.mavlink_system_id:
self.mavlink_system_id = int(os.getenv('MAV_SYSTEM_ID', 1))
if not self.mavlink_component_id:
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: Environment variable parsing may fail if MAV_SYSTEM_ID is not an integer.

Add error handling for non-integer MAV_SYSTEM_ID values to prevent ValueError exceptions.

@rmackay9
Copy link

Thanks very much for this!

@patrickelectric patrickelectric merged commit b1236ce into bluerobotics:master Oct 13, 2025
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

move-to-stable Needs to be cherry-picked and move to stable

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants